home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F45038_xsBreakLoop.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-07-22  |  976 b   |  35 lines

  1. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  2. <!-- This really needs a "break;" -->
  3.   <xsl:template name="maxCols">
  4.     <xsl:for-each select="//tr">
  5.       <xsl:sort select="count(td)" order="descending" />
  6.  
  7.       <xsl:if test="position() = 1">
  8.         <xsl:value-of select="." />
  9.       </xsl:if>
  10.     </xsl:for-each>
  11.   </xsl:template>
  12.  
  13. <!-- This doesn't need a "break;" -->
  14.   <xsl:template name="maxCols">
  15.     <xsl:apply-templates select="//tr[1]" mode="maxCols" />
  16.   </xsl:template>
  17.  
  18.   <xsl:template match="tr" mode="maxCols">
  19.     <xsl:variable name="next"
  20.     select="following-sibling::tr[count(td) > count(current()/td)][1]" />
  21.  
  22.     <xsl:choose>
  23.       <xsl:when test="$next">
  24.         <xsl:apply-templates select="$next" mode="maxCols" />
  25.       </xsl:when>
  26.  
  27.       <xsl:otherwise>
  28.         <xsl:value-of select="count(td)" />
  29.       </xsl:otherwise>
  30.     </xsl:choose>
  31.   </xsl:template>
  32. </xsl:stylesheet>
  33.  
  34.  
  35.